package com.tianma315.admin.produce.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.tianma315.admin.common.base.CoreServiceImpl;
import com.tianma315.admin.produce.VO.ScDisinfectVO;
import com.tianma315.admin.produce.domain.ScBatchingDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tianma315.admin.produce.dao.ScDisinfectDao;
import com.tianma315.admin.produce.domain.ScDisinfectDO;
import com.tianma315.admin.produce.service.ScDisinfectService;

import java.util.List;

/**
 * 
 * <pre>
 * 杀菌(生产)
 * </pre>
 * <small> 2019-05-30 09:53:18 | Aron</small>
 */
@Service
public class ScDisinfectServiceImpl extends CoreServiceImpl<ScDisinfectDao, ScDisinfectDO> implements ScDisinfectService {

    @Autowired
    private ScDisinfectDao scDisinfectDao;

    @Override
    public Page<ScDisinfectVO> getScDisinfectVOPage(Integer pageNumber, Integer pageSize, ScDisinfectDO scDisinfectDO) {
        Page<ScDisinfectVO> page = new Page<>(pageNumber,pageSize);
        page.setRecords(scDisinfectDao.getScDisinfectVOPage(scDisinfectDO.getProduceTaskId()));
        return page;
    }

    @Override
    public Boolean addScDisinfectDO(ScDisinfectDO scDisinfectDO) {
        scDisinfectDO.setState(0);
        return insert(scDisinfectDO);
    }

    @Override
    public Boolean deleteScDisinfectDO(Integer id) {
        ScDisinfectDO scDisinfectDO = new ScDisinfectDO();
        scDisinfectDO.setState(1);
        scDisinfectDO.setDisinfectId(id);
        return updateById(scDisinfectDO);
    }

    @Override
    public List<ScDisinfectDO> getScDisinfectDO(Integer produceTaskId) {
        Wrapper<ScDisinfectDO> wrapper = new EntityWrapper<>();
        wrapper.eq("state",0);
        wrapper.eq("produce_task_id",produceTaskId);
        List<ScDisinfectDO> scDisinfectDOList = selectList(wrapper);
        return scDisinfectDOList;
    }
}
